#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=100086;
ll T,n,m,L,V;//group of data   how many cars  how many assesses   total long     speed limit
ll d[N],v[N],a[N];//see downward
ll gap[N],lab[N];//the distance they touch limit,what assesses detect it.
ll p[N];// where is the assesseslla
ll ans,ans1;
int ac(int v1,int a1)//caculating after what distance travel ,the speed out/less limit    raw speed, accolration
{
    if(a1==0)
        return 0;
    return (pow(V,2)-pow(v1,2))/(2*a1);
}
bool det(int from,int to,bool jb)
{
    bool jj=0;
    if(jb==1)
    for(int i=from+1;i<=to;i++)
    {
        if(p[i]>0)
        {
            p[i]++;
            jj=1;
        }
    }
    if(jb==0)
    for(int i=from;i<to;i++)
    {
        if(p[i]>0)
        {
            p[i]++;
            jj=1;
        }
    }
    return jj;

}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%lld",&T);
    for(int tt=1;tt<=T;tt++)//groups
    {
        memset(d,0,sizeof(d));
        memset(a,0,sizeof(a));
        memset(v,0,sizeof(v));
        memset(gap,0,sizeof(gap));
        memset(p,0,sizeof(p));
        memset(lab,0,sizeof(lab));
        ans=0;ans1=0;
        scanf("%lld%lld%lld%lld",&n,&m,&L,&V);
        for(int i=1;i<=n;i++)//data of cars
        {
            //ll d,v,a;//start  raw velocity  accolration
            scanf("%lld%lld%lld",&d[i],&v[i],&a[i]);
            //cout<<ac(v,a)<<endl;
            gap[i]=ac(v[i],a[i]);
            //cout<<gap[i]<<endl;
        }

        for(int i=1;i<=m;i++)// input the location of assesses
        {
            ll pp;
            scanf("%lld",&pp);
            p[pp]++;
            //cout<<pp<<" "<<p[pp]<<endl;
        }

        for(int i=1;i<=n;i++)
        {
            if(a[i]<0 && v[i]>V)//negative
            {
                //det(d[i],d[i]+gap[i],0);
                if(det(d[i],d[i]+gap[i],0))
                    ans++;
            }
            else if (a[i]<0 && v[i]<=V)
            {
                continue;
            }
            else if(a[i]>0 && v[i]<=V)//positive
            {
                if(det(d[i]+gap[i],L,1))
                    ans++;

            }
            else if(a[i]>0 && v[i]>V)
            {
                if(det(d[i],L,1))
                        ans++;
            }
            else if(a[i]==0)//constant
            {
                if(v[i]>V)
                {
                    if(det(d[i],L,1))
                        ans++;
                }
                else if(v[i]<=V)
                {
                    continue;
                }
            }

        }
        //for(int i=1;i<=L;i++)
        //{
        //    if(p[i]>0)
        //        cout<<i<<" "<<p[i]<<endl;
        //}
        cout<<ans<<' '<<m-2<<endl;

    }
    return 0;
}
